#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int A = 0, B = 0,
    int count = 0, Adrk = 0, Bdrk = 0, Aout, Asch, Bout, Bsch;
    vector<int> As;
    vector<int> Bs;
    vector<int> Add;
    cin >> A >> B;
    cin >> count;
    for (size_t i = 0;i < count;i++)
    {
        int add = 0;
        cin >> Aout >> Asch >> Bout >> Bsch;
        add = Aout + Bout;
        As.push_back(Asch);
        Bs.push_back(Bsch);
        Add.push_back(add);
    }
    for (size_t i = 0;i < Add.size();i++)
    {
        if (As[i] == Add[i] && Bs[i] != Add[i])
        {
            A-=1;
            Adrk++;
            if (A < 0)
            {
                cout << 'A' << endl << Bdrk << endl;
                break;
            }
        }
        else if (Bs[i] == Add[i] && As[i] != Add[i])
        {
            B-=1;
            Bdrk++;
            if (B < 0)
            {
                cout << 'B' << endl << Adrk << endl;
                break;
            }
        }
    }
    return 0;
}
